package com.tencent.mid.b;

import android.content.Context;
import android.os.Environment;
import com.tencent.mid.util.Util;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;

public class c extends f
{
  public c(Context paramContext)
  {
    super(paramContext);
  }

  public int a()
  {
    return 2;
  }

  protected void a(a parama)
  {
  }

  protected void a(String paramString)
  {
    Object localObject;
    monitorenter;
    try
    {
      Util.logInfo("write mid to InternalStorage");
      localObject = new File(Environment.getExternalStorageDirectory(), g());
    }
    finally
    {
      try
      {
        localObject = new BufferedWriter(new FileWriter((File)localObject));
        ((BufferedWriter)localObject).write(l() + "," + paramString);
        ((BufferedWriter)localObject).write("\n");
        ((BufferedWriter)localObject).close();
        monitorexit;
        return;
      }
      catch (IOException paramString)
      {
        while (true)
          Util.logWarn(paramString);
        paramString = finally;
        monitorexit;
        throw paramString;
      }
    }
  }

  protected boolean b()
  {
    return ((!(Util.checkPermission(this.a, "android.permission.WRITE_EXTERNAL_STORAGE"))) || (!(Environment.getExternalStorageState().equals("mounted"))));
  }

  protected String c()
  {
    monitorenter;
    while (true)
    {
      Object localObject1;
      try
      {
        localObject1 = new File(Environment.getExternalStorageDirectory(), g());
      }
      finally
      {
        try
        {
          String[] arrayOfString;
          localObject1 = b.a((File)localObject1).iterator();
          do
          {
            if (!(((Iterator)localObject1).hasNext()))
              break label118;
            arrayOfString = ((String)((Iterator)localObject1).next()).split(",");
          }
          while ((arrayOfString.length != 2) || (!(arrayOfString[0].equals(l()))));
          Util.logInfo("read mid from InternalStorage:" + arrayOfString[1]);
          localObject1 = arrayOfString[1];
          monitorexit;
          return localObject1;
        }
        catch (IOException localObject3)
        {
          while (true)
          {
            Util.logWarn(localIOException);
            Object localObject2 = null;
          }
          localObject3 = finally;
          monitorexit;
          throw localObject3;
        }
      }
      label118: Object localObject4 = null;
    }
  }

  protected void d()
  {
    Object localObject1;
    monitorenter;
    try
    {
      localObject1 = new File(Environment.getExternalStorageDirectory(), g());
    }
    finally
    {
      try
      {
        localObject1 = new BufferedWriter(new FileWriter((File)localObject1));
        ((BufferedWriter)localObject1).write("");
        ((BufferedWriter)localObject1).close();
        monitorexit;
        return;
      }
      catch (IOException localObject2)
      {
        while (true)
          Util.logWarn(localIOException);
        localObject2 = finally;
        monitorexit;
        throw localObject2;
      }
    }
  }

  protected a e()
  {
    return null;
  }
}